#pragma once
#include "GLBase.h"
#include "OpenGLUtils.h"



#define GO_CHECK_GL_ERROR(...)   std::printf("CHECK_GL_ERROR %s glGetError = %d, line = %d, ",  __FUNCTION__, glGetError(), __LINE__)

class GLImageBeautyComplexionFilter : public GLBase
{
public:
	GLImageBeautyComplexionFilter();
	~GLImageBeautyComplexionFilter();


	//virtual void LoadImage(NativeImage *pImage);
	virtual void Init(int w, int h);
	virtual void onDrawFrameBegin();
	virtual Mat Draw( Mat frame);

	virtual void Destroy();

	bool CreateFrameBufferObj();
	//void setComplexionLevel(float level);

	void setComplexionLevel(float setSoomthValue, float BeautySkin, float Bright);

	
	
	
private:
	void setTexelOffset(float texelOffset);
	void setToneLevel(float toneLeve);
	void setBeautyLevel(float beautyLeve);
	void setBrightLevel(float brightLevel);
	void setParams(float beauty, float tone);
	void setTexelSize(float w, float h);
	void setFloat(int location, float floatValue);
	void setFloatVec2(int location, float* arrayValue);
	void setFloatVec3(int location, float* arrayValue);
	void setFloatVec4(int location, float* arrayValue);
	void setVec4(GLuint programId, float x, float y, float z, float w);

	Mat GetOcvImgFromOglImg(GLuint ogl_texture_id);
private:
	GLuint m_ImageTextureId;
	GLuint m_FboTextureId;
	
	GLuint m_FboId;
	GLuint m_VaoIds[2];
	GLuint m_VboIds[4];
	GLint m_SamplerLoc;
	GLuint m_FboProgramObj;
	GLuint m_FboVertexShader;
	GLuint m_FboFragmentShader;
	GLint m_FboSamplerLoc;
	int width, height, nrChannels;

	GLint paramsLoc;
	GLint brightnessLoc;
	GLint singleStepOffsetLoc;
	GLint texelWidthLoc;
	GLint texelHeightLoc;

	float toneLevel;
	float beautyLevel;
	float brightLevel;
	float texelWidthOffset;
	float texelHeightOffset;
	float msetSmoothLeve;

	float msetSoomthValue;  //ĥƤֵ
	float mBeautySkin;    //����
	float mBright;        //����

};

